# -*- coding: utf-8 -*-

from celery import Celery
from pathlib import Path


#  demo 名称自定义
app = Celery('demo')
app.config_from_object('celery_app.config')


def find_file(file_name, dir_path=None):
    """
    查找文件/目录
    :param dir: 查找目录
    :return: 绝对路径
    """
    if dir_path:
        instance = Path(dir_path)
    else:
        instance = Path.cwd() # 以本文件所在目录为查找目录
    f = instance.rglob(file_name)
    file_path = []
    file_dir = []
    for i in f:
        if i.is_file():
            file_path.append(i.__str__())
        else:
            file_dir.append(i.__str__())

    return file_dir, file_path